<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_admin.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.trade.ts_role.*" %>
<%@page import="com.lmpop.trade.ti_organize.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	
	Ti_admin ti_admin = new Ti_admin();

	String cust_id = "";	
	if( session.getAttribute("session_cust_id") != null ){
		cust_id = session.getAttribute("session_cust_id").toString();
	}

	ti_admin.setCust_id(cust_id);
	String u_name = "";
	if(request.getParameter("u_name")!=null && !request.getParameter("u_name").equals("")){
		u_name = request.getParameter("u_name");
		ti_admin.setUser_name(u_name);
	}
	String r_name = "";
	if(request.getParameter("r_name")!=null && !request.getParameter("r_name").equals("")){
		r_name = request.getParameter("r_name");
		ti_admin.setReal_name(r_name);
	}
	String role = "";
	if(request.getParameter("role")!=null && !request.getParameter("role").equals("")){
		role = request.getParameter("role");
		ti_admin.setRole_code(role);
	}
	String org = "";
	if(request.getParameter("org")!=null && !request.getParameter("org").equals("")){
		org = request.getParameter("org");
		ti_admin.setOrg_id(org);
	}
	String state = "";
	if(request.getParameter("state")!=null && !request.getParameter("state").equals("")){
		state = request.getParameter("state");
		ti_admin.setUser_state(state);
	}
	ti_admin.setUser_type("1");
	Ts_roleInfo ts_roleInfo = new Ts_roleInfo();
	Ti_organizeInfo ti_organizeinfo = new Ti_organizeInfo();
	Ti_adminInfo ti_adminInfo = new Ti_adminInfo();
	
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_adminInfo.getListByPage(ti_admin,Integer.parseInt(iStart),limit);
	int counter = ti_adminInfo.getCountByObj(ti_admin);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?u_name="+u_name+
	"&r_name="+r_name+"&role="+role+"&org="+org+"&state="+state+"&iStart=",Integer.parseInt(iStart),limit);
	
	String roleSelect = ts_roleInfo.getRoleBySelect(cust_id);
	String orgSelect  = ti_organizeinfo.getOrganizeByUpIdSelect(cust_id,"000000000000000");
	
	String para = "u_name="+u_name+
	"&r_name="+r_name+"&role="+role+"&org="+org+"&state="+state+"&iStart="+Integer.parseInt(iStart);
	
%>
<html>
  <head>
    
    <title>管理员用户管理</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
		<script type='text/javascript' src='/dwr/interface/Ti_organizeInfo.js'></script>
		<script type='text/javascript' src='/dwr/interface/Ti_adminInfo.js'></script>
		<script type='text/javascript' src='/dwr/engine.js'></script>
		<script type='text/javascript' src='/dwr/util.js'></script>
		<script type="text/javascript" src="admin.js" charset="UTF-8"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>管理员用户管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>您可以按“行业”或“关键字”订阅</h4>
		  <span>1、填写关键字，您将及时了解与该产品相关的所有商机。</span><br/>
		  <span>2、为了更准确订阅，建议你选择产品所属的行业大类和行业子类。</span>
		  </td>
        </tr>
      </table>
      <br/-->
	
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left">
				用户名:	<input name="u_name" type="text" size="10" />
				真实姓名:<input name="r_name" type="text" size="10" />
				状&nbsp;&nbsp;态:
					<select name="state">
						<option value="">请选择</option>
						<option value="0">启用</option>
						<option value="1">禁用</option>
					</select>
				
				角&nbsp;&nbsp;色:
					<select name="role">
						<option value="">请选择</option>
						<%=roleSelect%>
					</select>
							
				部&nbsp;&nbsp;门:
					<select name="sort1" id="sort1" onChange="setSecondClass(this.value);" >
						<option value="">请选择</option>
						<%=orgSelect%>
					</select>
					<select name="sort2" id="sort2"  onChange="setTherdClass(this.value);" style="display:none;">
						  <option value="">请选择</option>
					</select> 
					<select name="sort3" id="sort3" style="display:none;" >
						  <option value="">请选择</option>
					</select> 
					<input name="org" id="org" type="hidden" />
		
					<input name="searchInfo" type="button" value="查询" onClick="search()" />	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onClick="delIndexInfo(3)" value="删除" class="buttab"/>
				<input type="button" name="delInfo" onClick="delIndexInfo(2)" value="启用" class="buttab"/>
				<input type="button" name="delInfo" onClick="delIndexInfo(1)" value="禁用" class="buttab"/>
			</td>
			<td>
				总计:<%=counter%>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" border="0" class="listtab">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onClick="selectAll()"></th>
			
		  	<th>用户名</th>
		  	
		  	<th>真实姓名</th>
		  	
		  	<th width="25%">所在部门</th>
		  	
		  	<th width="25%">角色</th>
		  	
		  	<th>状态</th>
		  	
		  	<th width="10%">重置密码</th>
				<th width="5%">修改</th>
	  		<th width="5%">删除</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String user_id="",user_name="",real_name="",user_state="",user_type="",
		  			org_id="",role_code="",oper_date="",org_id_value="",role_code_value="";
		  			  	if(map.get("user_id")!=null) user_id = map.get("user_id").toString();
						  	if(map.get("user_name")!=null) user_name = map.get("user_name").toString();
						  	if(map.get("real_name")!=null) real_name = map.get("real_name").toString();
						  	if(map.get("user_type")!=null) user_type = map.get("user_type").toString();
						  	if(map.get("user_state")!=null) user_state = map.get("user_state").toString();
						  
						  	if(map.get("role_code") != null) {
						  		role_code = map.get("role_code").toString();
									String role_code_str[] = role_code.split("\\|");
									if(!role_code.equals("")){
										for(int k = 0;k < role_code_str.length;k++){
											role_code_value += ts_roleInfo.getNameByRoleCode(role_code_str[k]) + "&nbsp;";
										}
									}
						  	}
						  	if(map.get("org_id") != null) {
									org_id = map.get("org_id").toString();
									String org_id_str[] = org_id.split("\\|");
									if(!org_id.equals("")){
										for(int k = 0;k < org_id_str.length;k++){
											org_id_value += ti_organizeinfo.getOrgNameById(org_id_str[k]) + "&nbsp;";
										}
									}
								}
						  	if(map.get("oper_date")!=null) oper_date = map.get("oper_date").toString();
								if(oper_date.length()>19)oper_date=oper_date.substring(0,19);
		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i%>" id="checkone<%=i%>" value="<%=user_id%>" /></td>
			
		  	<td><%=user_name%></td>
		  	
		  	<td><%=real_name%></td>
		  	
		  	<td><%=org_id_value%></td>
		  	
		  	<td><%=role_code_value%></td>
		  	
		  	<td>
		  		<%
		  			if(user_state.equals("0")){ 
		  		%>
		  			<img src="/program/admin/images/yes.gif" title="启用" />
		  		<%
		  			}
		  		%>
		  		
		  		<%
		  			if(user_state.equals("1")){ 
		  		%>
		  			<img src="/program/admin/images/no.gif" title="禁用" />
		  		<%
		  			}
		  		%>
		  	
		  	</td>
		  	<td width="10%"><a href="updatePasswd.jsp?user_id=<%=user_id%>&<%=para%>">重置密码</a></td>
			<td width="5%"><a href="updateInfo.jsp?user_id=<%=user_id%>&<%=para%>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  		<td width="5%"><a href="javascript:delOneNews('<%=user_id%>');"><img src="/program/admin/images/delete.gif" title="删除" /></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onClick="delIndexInfo(3)" value="删除" class="buttab"/>
				<input type="button" name="delInfo" onClick="delIndexInfo(2)" value="启用" class="buttab"/>
				<input type="button" name="delInfo" onClick="delIndexInfo(1)" value="禁用" class="buttab"/>
			</td>
			<td>
				总计:<%=counter%>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td align="center"><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize%>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="user_state" id="user_state" value="" />
	  <input name="cust_id" id="cust_id" type="hidden" value="<%=cust_id%>" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="" />
	  </form>
</body>

</html>
